package cn.edu.neusoft.maxingxin231.yuejian06.Adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.maxingxin231.yuejian06.Activity.DetailActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Activity.MasterDetailActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.MasterBean;

public class MasterAdapter extends Base2Adapter<MasterBean> {
    String coach_id,coach_name,coach_img,coach_ismaster,club_id,att_num;
    public MasterAdapter(Context context, List<MasterBean> items, int layoutResource) {
        super(context, items, layoutResource);
    }
    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        MasterBean masterBean = items.get(position);
        if(masterBean ==null) return;
        final ClubViewHolder clubViewHolder = (ClubViewHolder) holder;

        final String coach_name=items.get(position).getCoach_name();
        final String coach_des=items.get(position).getCoach_des();
        final String coach_id=items.get(position).getCoach_id();
        final String att_num=items.get(position).getAtt_num();
        final String coach_img=items.get(position).getCoach_img();
        final String coach_ismaster=items.get(position).getCoach_ismaster();
        final String club_id=items.get(position).getClub_id();
        clubViewHolder.c_tv1.setText(coach_name);
        clubViewHolder.c_tv2.setText(coach_des);
        Picasso.with(context).load("http://10.0.2.2:80/yuejian14/public/static/coach/"+items.get(position).getCoach_img()).into(clubViewHolder.c_img1);
        clubViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //条目点击事件
                Log.i("TEST","onClick");
                Intent intent = new Intent(context,MasterDetailActivity.class);
                intent.putExtra("coach_id",coach_id);
                intent.putExtra("coach_name",coach_name);
                intent.putExtra("coach_img",coach_img);
                intent.putExtra("coach_ismaster",coach_ismaster);
                intent.putExtra("club_id",club_id);
                intent.putExtra("att_num",att_num);
                context.startActivity(intent);
            }
        });

    }
    public void setList(List<MasterBean> list){
        this.items = list;
        notifyDataSetChanged();
    }
}
